﻿CREATE VIEW [acms].[UserPostVoteAverage_View]
AS 
	SELECT 
		a.PostId,
		b.SiteId,
		b.Name as PostName,
		b.DisplayName as PostDisplayName,
		AVG(a.Score) as Average,
		Count(a.Id) as Total
	FROM UserPostVote a 
		inner join Posts b on a.PostId = b.Id
	Where b.Deleted = 0
	GROUP BY 		
		a.PostId,
		b.SiteId,
		b.Name,
		b.DisplayName
